package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.service.SetmealService;
import com.itheima.vo.DishWithFlavorVo;
import com.itheima.vo.SetmealAndCategory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 小帅蓝
 * @Date 2022/6/23 20:30
 */
@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Resource
    private SetmealService setmealService;

    /**
     * 菜品详情
     *
     * @param setmealId setmealId
     * @return R<List < DishWithFlavorVo>>
     */
    @GetMapping("/dish/{setmealId}")
    public R<List<DishWithFlavorVo>> setmealList(@PathVariable("setmealId") String setmealId) {
        return R.success(setmealService.selectListById(setmealId));
    }

    /**
     * 套餐列表
     *
     * @param categoryId 菜品分类id
     * @param status     状态：0-停用，1-启用
     * @return R<List < SetmealAndCategory>>
     */
    @GetMapping("/list")
    public R<List<SetmealAndCategory>> selectList(String categoryId, Integer status) {
        return R.success(setmealService.selectList(categoryId, status));
    }

}
